﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Rechy.RechyVSTool
{
    public partial class FormStatistics : Form
    {
        private int allLineCount = 0;
        public FormStatistics()
        {
            InitializeComponent();
        }

        internal void Init()
        {
            LoadData();
        }

        private void FormStatistics_Load(object sender, EventArgs e)
        {

            listViewData.GridLines = true;//显示各个记录的分隔线
            listViewData.FullRowSelect = true;//要选择就是一行
            listViewData.View = View.Details;//定义列表显示的方式
            listViewData.Scrollable = true;//需要时候显示滚动条
            listViewData.MultiSelect = false; // 不可以多行选择
            listViewData.HeaderStyle = ColumnHeaderStyle.Clickable;

            LoadData();
        }

        public void LoadData()
        {
            allLineCount = 0;
            labelAllLineCount.Text = allLineCount.ToString();
            listViewData.Clear();
            listViewData.Columns.Add("col1", "文件名");
            listViewData.Columns.Add("col2", "代码行数");
            listViewData.Visible = true;
        }

        internal void AddData(string fileName, int p)
        {
            allLineCount += p;

            ListViewItem item = new ListViewItem();
            item.Text = fileName;
            item.SubItems.Add(p.ToString());
            listViewData.Items.Add(item);

            labelAllLineCount.Text = allLineCount.ToString();
            listViewData.Columns["col1"].Width = -1;
            listViewData.Columns["col2"].Width = -1;
        }
    }
}
